<!DOCTYPE html>
<html>
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title></title>
  </head>
  <body>
    <div id="app">
      <btn-add></btn-add>
    </div>
    <div id="app2">
      <btn-add></btn-add>
    </div>
    <script src="./vue.js"></script>
    <script>
      const vm = new Vue({
        el: '#app',
        // 局部注册组件
        components: {
          'btn-add': {
            template: '<div>结果：{{count}} <button @click="add()">累加</button></div>',
            data () {
              return {
                count: 0
              }
            },
            methods: {
              add () {
                this.count ++
              }
            }
          }
        }
      })
      const vm2 = new Vue({
        el: '#app2'
      })
    </script>
  </body>
</html>